{% extends "../page.html" %}

{% block content %}
<table type="yunj" id="{{ data.builderId }}"></table>
{% endblock %}

{% block script %}
<script type="text/javascript">
    layui.use(["jquery", 'yunj'], function () {
        let win = window;
        let doc = document;
        let $ = layui.jquery;

        class ListHandler{
            constructor(args) {
                this.args = args;
                this.tableBuilderId = args.tableBuilderId;
                this.init();
            }

            init() {
                let that = this;
                that.setEventBind();
            }

            setEventBind(){
                let that = this

                // 绑定渲染完成后的事件
                $(doc).bind(`yunj_table_${that.tableBuilderId}_export_file_download`, function (e, args) {
                    let url = args.layEventObj.data.export_file_download_url;
                    if (url!="") {
                        yunj.download(url)
                    } else {
                        yunj.error("当前任务导出文件下载地址异常");
                    }
                });
            }
        }

        $(doc).ready(function () {
            new ListHandler({
                tableBuilderId: '{{ data.builderId }}',
            });
        });

    });
</script>
{% endblock %}